Ext.setup({
    icon: 'icon.png',
    tabletStartupScreen: 'tablet_startup.png',
    phoneStartupScreen: 'phone_startup.png',
    glossOnIcon: false,
    onReady: function() {
		var _fullscreen = Ext.is.Phone ? true : false;
        var form;

		// Login Page
        Ext.regModel('User', {
            fields: [
                {name: 'uid',     type: 'string'},
                {name: 'upw', type: 'password'}
            ]
        });
        
        var formBase = {
			fullscreen: true,
            // scroll: 'vertical',
            url   : '/cat/login_proc',
            standardSubmit : false,
            items: [
                {
                    xtype: 'fieldset',
                    title: 'Login',
                    instructions: 'Please enter the information above.',
                    defaults: {
                        required: true,
                        labelAlign: 'left',
                        labelWidth: '40%'
                    },
                    items: [
                    {
                        xtype: 'textfield',
                        name : 'uid',
                        label: 'ID',
                        useClearIcon: true,
                        autoCapitalize : false
                    }, {
                        xtype: 'passwordfield',
                        name : 'upw',
                        label: 'Password',
                        useClearIcon: false
                    }]
                }
            ],
            listeners : {
                submit : function(form, result){
                    redirect_to = result.data.redirect_to;
					window.location = redirect_to;
                },
                exception : function(form, result){
                    Ext.Msg.alert('Login Failed', result.message, Ext.emptyFn);
                }
            },
        
            dockedItems: [
                {
                    xtype: 'toolbar',
                    dock: 'bottom',
                    items: [
                        {xtype: 'spacer'},
                        {
                            text: 'Login',
							ui: 'confirm',
                            handler: function() {
                                if(formBase.user){
                                    form.updateRecord(formBase.user, true);
                                }
                                form.submit({
                                    waitMsg : {message:'Login....', cls : 'waiting-mask'}
                                });
                            }
                        },
                        {
                            text: 'Join',
                            handler: function() {
                                form.reset();
                            }
                        }
                    ]
                }
            ]
        };

        form = new Ext.form.FormPanel(formBase);
        form.show();
    }
});